package com.blog.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.blog.entity.SysPlace;
import com.blog.mapper.SysPlaceMapper;
import com.blog.service.SysPlaceService;

import com.blog.util.dto.AjaxResult;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author cgx
 * @Date 2021/9/1 20:23
 */
@Service
public class SysPlaceServiceImpl extends ServiceImpl<SysPlaceMapper, SysPlace> implements SysPlaceService {
    
    @Resource
    SysPlaceMapper placeMapper;
    
    
    @Override
    public AjaxResult delPlaceById(String id) {
        QueryWrapper<SysPlace> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("pid",id);
        List<SysPlace> list = placeMapper.selectList(queryWrapper);
        if (list.size() > 0){
            return AjaxResult.error("该地点下存在信息,不允许删除");
        }else{
            placeMapper.deleteById(id);
            return AjaxResult.success();
        }
    }
}
